/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package guiutilities;

import image.edge.EdgeDetector.DIRECCTION;
import image.edge.SusanEdgeDetector.SUSAN_TYPES;
import image.processing.ImageProcessor.CompressAlgorithm;
import java.awt.Dimension;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import org.jdesktop.application.ResourceMap;

/**
 *
 * @author tommy
 */
public class jSusanDialog extends JDialog {
	private boolean confirmed;
	private JLabel jHeader;
	private ButtonGroup optionsGroup;
	private JRadioButton jBorders, jCorners, jBoth, jNone;
	private JCheckBox jCheckBoxOverImg;
	private JButton jConfirmOperation;
	
	
	public jSusanDialog(JFrame parent, ResourceMap resourceMap) {
		// Dialog for browsing and storing 2 images to perform operations among
		// them
		super(parent,"Select type", true);
		
		getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.PAGE_AXIS));
		setPreferredSize(new Dimension(512,196));
		setMaximumSize(new Dimension(512,196));
		setResizable(false);
		setSize(512, 196);
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
		
		jHeader = new JLabel("Choose type: ");
		
		optionsGroup = new ButtonGroup();
		jBorders = new JRadioButton("Edges");
		jCorners = new JRadioButton("Corners", true);
		jBoth = new JRadioButton("Both");
		jNone = new JRadioButton("None");

		optionsGroup.add(jBorders);
		optionsGroup.add(jCorners);
		optionsGroup.add(jBoth);
		optionsGroup.add(jNone);
		
		jCheckBoxOverImg = new JCheckBox("Over Image?");
		
		jConfirmOperation = new JButton();
        jConfirmOperation.setText(resourceMap.getString("jConfirmOperation.text")); // NOI18N
        jConfirmOperation.setName("jConfirmOperation"); // NOI18N
		jConfirmOperation.setPreferredSize(new Dimension(50,50));
		jConfirmOperation.setMinimumSize(new Dimension(50,50));
        jConfirmOperation.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jConfirmOperationActionPerformed(evt);
            }
        });
		
		// Add components to Dialog
		getContentPane().add(jHeader);
		getContentPane().add(jBorders);
		getContentPane().add(jCorners);
		getContentPane().add(jBoth);
		getContentPane().add(jNone);
		getContentPane().add(jCheckBoxOverImg);
		getContentPane().add(jConfirmOperation);
	
	}
	
	public boolean isConfirmed() {
		return this.confirmed;
	}
	
	public SUSAN_TYPES getSusanType() {
		SUSAN_TYPES type = SUSAN_TYPES.CORNERS;
		
		if (isConfirmed()) {
			if (jBorders.isSelected()) {
				type = SUSAN_TYPES.BORDERS;
			} else if (jCorners.isSelected()) {
				type = SUSAN_TYPES.CORNERS;
			} else if (jBoth.isSelected()){
				type = SUSAN_TYPES.BOTH;
			} else {
				type = SUSAN_TYPES.NONE;
			}
		}
		
		return type;
	}
	
	public boolean getOverImage(){
		return jCheckBoxOverImg.isSelected();
	}
		
	private void jConfirmOperationActionPerformed(java.awt.event.ActionEvent evt) {                                                     
		this.confirmed = true;
		this.dispose();
	}
}
